package com.apps.goods.model.po;

import java.math.BigDecimal;

import com.apps.sannotation.constraints.*;
import com.apps.sannotation.identity.CatId;
import com.apps.sannotation.identity.GmtCreate;
import com.apps.sannotation.identity.GmtModify;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.solr.client.solrj.beans.Field;
import org.springframework.data.solr.core.mapping.SolrDocument;

/**
 * <p>
 * 
 * </p>
 *
 * @author 大鹏
 * @since 2020-10-02
 */
@SolrDocument(solrCoreName = "new_core")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("kupa_goods")
public class KupaGoods implements Serializable {

    private static final long serialVersionUID = 1L;

    @Field
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 商品所属分类
     */
    @Field
    @CatId
    private Integer goods_cat_id;

    /**
     * 商品名
     */
    @Field
    @NoNull(errMsg = "商品名不能为空")
    private String goods_name;

    /**
     * 描述
     */
    @Field
    @StrDef("")
    @NoNull
    private String goods_describe;

    /**
     * 关键词
     */
    @Field
    @StrDef("")
    @NoNull
    private String goods_keyworld;

    /**
     * 缩略图,一个json数组
     */
    @Field
    @StrDef("")
    @NoNull
    private String goods_thumbnail;

    /**
     * 原始下载地址
     */
    @Field
    @NoNull
    private String goods_download;

    /**
     * 商品价格
     */
    @Field
    @NumDef(value = 0,Cla = BigDecimal.class)
    @NoNull
    private Float goods_price;

    /**
     * 详情介绍
     */
    @Field
    @StrDef("")
    @NoNull
    private String goods_context;

    /**
     * 0=互联网资源,1=自有资源
     */
    @Field
    @NumRange(min = 0,max = 1)
    @NoNull
    private Integer goods_type;

    /**
     * 文件大小,M为单位
     */
    @Field
    @NumDef(value = 0,Cla = Float.class)
    private Float goods_size;

    /**
     * 文件格式
     */
    @Field
    @StrDef("未知")
    private String goods_format;

    /**
     * 打开软件
     */
    @Field
    @StrDef("未知")
    private String goods_open_software;
    /**
     * 被收藏的次数
     */
    @Field
    @NumDef(0)
    private Integer goods_collect_num;

    /**
     * 被评论的次数
     */
    @Field
    @NumDef(0)
    private Integer goods_comment_num;
    /**
     * 被浏览次数
     */
    @Field
    @NumDef(0)
    private Integer goods_view_num;
    /**
     * 被点赞的总次数
     */
    @Field
    @NumDef(0)
    private Integer goods_like_num;

    /**
     * 素材的phash值
     */
    @Field
    @StrDef("")
    private String p_hash;

    @Field
    @GmtCreate(Cla = Long.class)
    private Long gmt_create;
    @Field
    @GmtModify(Cla = Long.class)
    private Long gmt_modify;
    @Field
    @StrDef("")
    private String remark;


    public KupaGoods()
    {

    }

    public KupaGoods(org.apache.solr.common.SolrDocument document)
    {
        this.id = Integer.valueOf(document.getFieldValue("id").toString());
        this.goods_cat_id = Integer.valueOf(document.getFieldValue("goods_cat_id").toString());
        this.goods_name = null != document.getFieldValue("goods_name") ? document.getFieldValue("goods_name").toString():"";
        this.goods_describe = null != document.getFieldValue("goods_name") ? document.getFieldValue("goods_describe").toString():"";
        this.goods_keyworld = null != document.getFieldValue("goods_keyworld") ? document.getFieldValue("goods_keyworld").toString():"";
        this.goods_thumbnail = null != document.getFieldValue("goods_thumbnail") ? document.getFieldValue("goods_thumbnail").toString():"";
        this.goods_download = null != document.getFieldValue("goods_download") ? document.getFieldValue("goods_download").toString():"";
        this.goods_price = Float.valueOf(document.getFieldValue("goods_price").toString());
        this.goods_context = null != document.getFieldValue("goods_context") ? document.getFieldValue("goods_context").toString():"";
        this.goods_type =Integer.valueOf(document.getFieldValue("goods_type").toString());
        this.goods_size = Float.valueOf(document.getFieldValue("goods_size").toString());
        this.goods_format = null != document.getFieldValue("goods_format") ? document.getFieldValue("goods_format").toString():"";
        this.goods_open_software = document.getFieldValue("goods_open_software").toString();
        this.goods_collect_num = Integer.valueOf(document.getFieldValue("goods_collect_num").toString());
        this.goods_comment_num = Integer.valueOf(document.getFieldValue("goods_comment_num").toString());
        this.goods_view_num = Integer.valueOf(document.getFieldValue("goods_view_num").toString());
        this.goods_like_num = Integer.valueOf(document.getFieldValue("goods_like_num").toString());
        this.gmt_create = Long.valueOf(document.getFieldValue("gmt_create").toString());
        this.gmt_modify = Long.valueOf(document.getFieldValue("gmt_modify").toString());
        this.remark = null != document.getFieldValue("remark") ? document.getFieldValue("remark").toString():"";
    }

    public static final String ID = "id";

    public static final String GOODS_CAT_ID = "goods_cat_id";

    public static final String GOODS_NAME = "goods_name";

    public static final String GOODS_DESCRIBE = "goods_describe";

    public static final String GOODS_KEYWORLD = "goods_keyworld";

    public static final String GOODS_THUMBNAIL = "goods_thumbnail";

    public static final String GOODS_DOWNLOAD = "goods_download";

    public static final String GOODS_PRICE = "goods_price";

    public static final String GOODS_CONTEXT = "goods_context";

    public static final String GOODS_TYPE = "goods_type";

    public static final String GOODS_COLLECT_NUM = "goods_collect_num";

    public static final String GOODS_COMMENT_NUM = "goods_comment_num";

    public static final String GOODS_LIKE_NUM = "goods_like_num";

    public static final String GMT_CREATE = "gmt_create";

    public static final String GMT_MODIFY = "gmt_modify";

    public static final String REMARK = "remark";

}
